<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="jquery-3.6.0.js"></script>
    
    <style>
        div.box{
            width: 500px;
            height: 200px;
            background-color: pink;
        }
    </style>
</head>
<body>
    <form name="myform">
        <p>速度</p>
        <input type="radio" name="Down" value="slow"> slow
        <input type="radio" name="Down" value="normal"> normal
        <input type="radio" name="Down" value="fast"> fast<br>
        <input type="range" name="T" > range<br>
        <input type="number" name="a1" value="">
        <br>
        <p>动画效果</p>
        <input type="radio" name="Up" value="swing"> swing
        <input type="radio" name="Up" value="linear"> linear
    </form> 
    <p></p>
    <button data-type="fadeIn">淡入</button>
    <button data-type="fadeOut">淡出</button>
    <button data-type="opacity">透明</button>
    <p></p>
    <div class="box"></div>
    <script>

        $('button').click(function() {
            let type = this.dataset.type;
            let elements = document.forms.myform.elements;

            let Down = elements.Down.value;
            let Up = elements.Up.value;
            let opacity = elements.T.value / 10;
            let a2 = elements.a1.value;
            

            if (type === 'fadeIn') {
                $('div').fadeIn([Down],opacity,[Up])
            } else if (type === 'fadeOut') {
                $('div').fadeOut([Down],opacity,[Up])
            } else if(type === 'opacity'){
                $('div').fadeTo(Down,opacity)
            }
        })
    </script>
</body>
</html>

